package myschool.web;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author oldliu
 * @since 1.0
 */
public class HelloServlet extends HttpServlet {
    @Override//处理get请求
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.print("<h1>");
        out.print("你好，我是渣渣灰");
        out.print("</h1>");
    }

    @Override//处理post请求
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.print("<html>");
        out.print("<body>");
        out.print("<div style='color:red;'>83班同学，下午好</div>");
        out.print("<h1>");
        out.print("你好，我不是渣渣灰，This is a post请求");
        out.print("</h1>");
        out.print("</body>");
        out.print("</html>");
    }
}
